import { defineStore } from 'pinia'

const useHome = defineStore('home', {
  state: () => ({
    banners: [],
    recommends: [],
  }),
  actions: {
    /* async fetchHomeMultidata() {
			const res = await fetch('http://123.207.32.32:8000/home/multidata')
			const data = await res.json()
			this.banners = data.data.banner.list
			this.recommends = data.data.recommend.list

			return '完成了'
		}, */

    fetchHomeMultidata() {
      return new Promise((resolve) => {
        fetch('http://123.207.32.32:8000/home/multidata')
          .then((res) => {
            return res.json()
          })
          .then((data) => {
            this.banners = data.data.banner.list
            this.recommends = data.data.recommend.list

            resolve('完成了')
          })
      })
    },
  },
})

export default useHome
